    //
    //  OrderMarryController.m
    //  quxiangtao
    //
    //  Created by HHuajiang on 2018/11/9.
    //  Copyright © 2018 shanhaijin. All rights reserved.
    //

#import "OrderMarryController.h"
#import "MatchingController.h"
#import "TbOrderWebViewController.h"
#import <AlibcTradeSDK/AlibcTradeSDK.h>
#import "ZXSegmentController.h"
#import "OrderPController.h"
@interface OrderMarryController ()
@property (nonatomic, weak) UITextField *textfield;
@property (nonatomic, weak) UITextField *nameTextfield;
@property (nonatomic, weak) UITextField *moneyTextfield;
@property (nonatomic, weak) ZXSegmentController *segmentController;
@property (nonatomic, assign) NSInteger indexType;
@end

@implementation OrderMarryController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"订单匹配";
    self.view.backgroundColor = [UIColor colorWithHexString:@"#f2f2f2"];
    
    UIButton *settingButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [settingButton addTarget:self action:@selector(settingButtonOnClicked) forControlEvents:UIControlEventTouchUpInside];
    settingButton.titleLabel.font = [UIFont systemFontOfSize:13];
    [settingButton setTitleColor:Color333333 forState:UIControlStateNormal];
    [settingButton setTitle:@"匹配记录" forState:UIControlStateNormal];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:settingButton];
    self.navigationItem.rightBarButtonItem = rightItem;
    
    OrderPController *taobaoCtr = [[OrderPController alloc] init];
    taobaoCtr.IndexType = 1;
    
    OrderPController *jingDongCtr = [[OrderPController alloc] init];
    jingDongCtr.IndexType = 2;
    
    NSArray* names = @[@"淘宝订单匹配",@"京东订单匹配"];
    NSArray* controllers = @[taobaoCtr,jingDongCtr];
    
    ZXSegmentController* segmentController = [[ZXSegmentController alloc] initWithControllers:controllers
                                                                               withTitleNames:names
                                                                             withDefaultIndex:0
                                                                               withTitleColor:[UIColor colorWithHexString:@"#333333"]
                                                                       withTitleSelectedColor:[UIColor blackColor]
                                                                              withSliderColor:[UIColor redColor]];
    segmentController.enableSwipeGestureRecognizer = YES;
    [self addChildViewController:(_segmentController = segmentController)];
    [self.view addSubview:segmentController.view];
    [segmentController didMoveToParentViewController:self];
    [self createAutolayout];
    
    WS(weakSelf);
    segmentController.selectedBlock = ^(NSInteger index) {
        weakSelf.indexType = index;
    };
    
}



- (void)createAutolayout{

    [_segmentController.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(0.5);
        make.height.mas_equalTo(HEIGHT-Height_NavBar);
    }];
}



- (void)settingButtonOnClicked {
    MatchingController *matchingCtr = [[MatchingController alloc] init];
    matchingCtr.indexll = self.indexType == 0 ? 1 : 2;
    [self.navigationController pushViewController:matchingCtr animated:YES];
}

@end
